#include "config.h"
#include "sys_tim.h"
#include "task_handler.h"
#include "watch_dog.h"
#include "uart_drv.h"
#include "dev_comm.h"
#include "beep_drv.h"
#include "button_drv.h"
#include "display_task.h"
#include "modbus_user.h"
#include "modbus_poll.h"
#include "modbus_slave.h"

#define TASK_NUM   sizeof(taskList) / sizeof(taskList[0])

static TaskConfig_t taskList[] =  
{
    {0, 3000, WDT_Clear},
    {0, 20,   Button_Scan},
    {0, 300,  DisplayTask},
    {0, 50,   ModbusMasterProcess},
};  
/**
* @brief 任务调度
* @param None
* @return None
*/
void App_Task_Handler(void)
{
    u8 i = 0;

    while(1)
    {
        for(i = 0; i < TASK_NUM; i++)
        {
            if(GetTick() - taskList[i].LastRunTime >=
                                       taskList[i].Interval)
            {
                taskList[i].LastRunTime += taskList[i].Interval;
                taskList[i].pFunc();
            }
        }
        ModbusSlaveProcess(&slave, uart1.queue);
    }    
}


